package org.openkanban.client.ui.presenter;

import org.openkanban.client.ui.board.BoardView;
import org.openkanban.client.util.RootPanel;
import org.openkanban.shared.dto.BoardDto;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;

/**
 * Callback that handles update board request
 */
public class UpdateBoardRequestCallback implements RequestCallback {

    @Override
    public void onResponseReceived(Request request, Response response) {
	BoardView boardView = RootPanel.main.getBoard();

	if (response.getStatusCode() == 200) {
	    BoardDto boardDto = new BoardDto(response.getText());
	    boardView.getWhiteBoardView().setBoardDto(boardDto);
	    boardView.publish();
	}
    }

    @Override
    public void onError(Request request, Throwable exception) {
    }

}
